<template>
  <div class="app-container">
    <!-- 顶部 -->
      <mt-header fixed title="电商vue项目">
        <span slot="left" @click="goBack" v-show="isback">
          <mt-button icon="back">返回</mt-button>
        </span>
      </mt-header>
    <!-- 中部 -->
    <transition>
      <router-view />
    </transition>
    

    <!-- 尾部 -->
    <nav class="mui-bar mui-bar-tab">
      <router-link class="mui-tab-item" to="/home">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
      </router-link>
      <router-link class="mui-tab-item" to="/goodslist">
        <span class="mui-icon mui-icon-extra mui-icon-extra-cart"></span>
        <span class="mui-tab-label">商城</span>
      </router-link>
      <router-link class="mui-tab-item" to="/shopcar">
        <span class="mui-icon mui-icon-extra mui-icon-extra-cart">
          <span class="mui-badge" id="bag">0</span>
        </span>
        <span class="mui-tab-label">购物车</span>
      </router-link>
      <router-link class="mui-tab-item" to="/member">
        <span class="mui-icon mui-icon-contact"></span>
        <span class="mui-tab-label">会员</span>
      </router-link>
    </nav>
  </div>
</template>

<script>
export default {
  data(){
    return{
      isback:true
    }
  },
  mounted() {
    if (this.$route.path === "/home") {
      this.isback = false;
    } else {
      this.isback = true;
    }
    //console.log(this.totalcount);
    //this.cunt=this.totalcount;
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    }
  },
  watch: {
    "$route.path": function(s1, s2) {
      // console.log(s1+"-----"+s2);
      if (s1 === "/home") {
        this.isback = false;
      } else {
        this.isback = true;
      }
    }
  }
};
</script>

<style scoped>
.app-container {
  width: 100%;
  height: 100%;
  padding: 40px 0 50px 0;
  overflow: hidden;
}

 /* 动画 */
.v-enter {
  opacity: 0;
  transform: translateX(100%);
}
.v-leave-to {
  opacity: 0;
  transform: translateX(-100%);
  position: absolute;
}

.v-enter-active,
.v-leave-active {
  transition: all 1s ease;
}
.mint-header {
  z-index: 99;
}
</style>
